﻿using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WPS.SDK.model.yunfile
{
    /// <summary>
    /// 上传路径对象
    /// </summary>
    public class UploadUrlData
    {
        public string authorization;
        public string upload_url;
        public string date;
        public string content_type;
        public string x_kss_newfilename_in_body;
        public long result;
        public static UploadUrlData fromJsonObject(JObject jsonObject)
        {
            UploadUrlData uploadUrlData = new UploadUrlData();
            JObject data = null;
            JObject request_header = null;
            if (jsonObject["data"] != null)
            {
                data = JsonConvert.DeserializeObject<JObject>(jsonObject["data"].ToString());
            }
            if (data == null)
            {
                return uploadUrlData;
            }
            if (data["request_header"] !=null)
            {
                request_header = JsonConvert.DeserializeObject<JObject>(data["request_header"].ToString());
            }
            if (request_header == null)
            {
                return uploadUrlData;
            }
            if (jsonObject["result"] != null)
            {
                uploadUrlData.result = Convert.ToInt64(jsonObject["result"]);
            }
            uploadUrlData.upload_url = data["upload_url"].ToString();
            uploadUrlData.authorization = request_header["authorization"].ToString();
            uploadUrlData.date = request_header["date"].ToString();
            uploadUrlData.content_type = request_header["content_type"].ToString();
            uploadUrlData.x_kss_newfilename_in_body = request_header["x-kss-newfilename-in-body"].ToString();
            return uploadUrlData;
        }
    }
}
